package com.myBlog.controller;

import com.myBlog.domain.ResponseResult;
import com.myBlog.domain.dto.MenuDTO;
import com.myBlog.domain.vo.PageVo;
import com.myBlog.service.MenuService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Resource
    private MenuService menuService;

    /**
     * 菜单列表
     *
     * @param menuName
     * @param status
     * @return
     */
    @GetMapping("/list")
    public ResponseResult list(String menuName, String status) {
        return menuService.list(menuName, status);
    }

    /**
     * 根据id查询菜单信息
     *
     * @param menuId
     * @return
     */
    @GetMapping("{id}")
    public ResponseResult getMenuInfo(@PathVariable("id") Long menuId) {
        return menuService.getMenuInfo(menuId);
    }

    /**
     * 添加菜单
     * @param menuDTO
     * @return
     */
    @PostMapping
    public ResponseResult addMenu(@RequestBody MenuDTO menuDTO) {
        return menuService.addMenu(menuDTO);
    }

    /**
     * 修改菜单
     * @param menuDTO
     * @return
     */
    @PutMapping
    public ResponseResult updateMenu(@RequestBody MenuDTO menuDTO) {
        return menuService.updateMenu(menuDTO);
    }

    /**
     * 根据id删除菜单
     * @param menuId
     * @return
     */
    @DeleteMapping("{id}")
    public ResponseResult deleteMenu(@PathVariable("id") Long menuId) {
        return menuService.deleteMenu(menuId);
    }

    /**
     * 根据id查询权限菜单
     * @param roleId
     * @return
     */
    @GetMapping("/roleMenuTreeselect/{id}")
    public ResponseResult roleMenuTreeSelect(@PathVariable("id") Long roleId) {
        return menuService.roleMenuTreeSelect(roleId);
    }

    /**
     * 新增角色
     * @return
     */
    @GetMapping("/treeselect")
    public ResponseResult getMenuTree() {
        return menuService.getMenuTree();
    }


}
